package team.niit.ict.fragment;

import team.niit.ict.mydoctor.R;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ViewFlipper;

public class KhamBenh extends Fragment {
	
	private View view;
	private ViewFlipper viewFlipper;
	private EditText txtSearch;
	private Bundle myBundle;
	private int sex; 
	private int area;
	
	
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub

		view = inflater.inflate(R.layout.khambenh, container, false);
		viewFlipper = (ViewFlipper) view.findViewById(R.id.viewFlipper);
		
		//Gioi tinh
		ImageButton btnMan, btnWoman;
		btnMan = (ImageButton) view.findViewById(R.id.btnMan);
		btnWoman = (ImageButton) view.findViewById(R.id.btnWoman);
		btnMan.setOnClickListener(GennerListener);
		btnWoman.setOnClickListener(GennerListener);
		
		//Khu vuc bi benh
		Button dau, giua, duoi, toanthan;
		dau = (Button) view.findViewById(R.id.btnHeader);
		giua = (Button) view.findViewById(R.id.btnCenter);
		duoi = (Button) view.findViewById(R.id.btnFooter);
		toanthan  = (Button) view.findViewById(R.id.btnTotal);
		dau.setOnClickListener(AreaListener);
		giua.setOnClickListener(AreaListener);
		duoi.setOnClickListener(AreaListener);
		toanthan.setOnClickListener(AreaListener);

		return view;
	}


	/**
	 * Phương thức NextViewFlipper;
	 */
	public void nextViewPlipper() {
		viewFlipper.setInAnimation(getActivity(), R.anim.innext);
		viewFlipper.setOutAnimation(getActivity(), R.anim.outnext);
		viewFlipper.showNext();
	}

	/**
	 * Xử lý sự kiện khi chọn giới tính
	 */
	OnClickListener GennerListener = new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			nextViewPlipper();
			sex = Integer.parseInt(v.getTag().toString());
		}
	};

	/**
	 * Xử lý sự kiện khi chọn vị trí
	 */
	OnClickListener AreaListener = new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			nextViewPlipper();
			area = Integer.parseInt(v.getTag().toString());
		}
	};
}
